package 算法.leetcode.labuladong.数组和链表;

/**
 * @author lchenglong
 * @date 2022/6/16
 */
public class 删除有序数组中的重复项 {
    class Solution {
        public int removeDuplicates(int[] nums) {
            //边界条件
            if (nums.length == 0)return 0;
            int fast=0,slow=0;
            while (fast<nums.length){
                if (nums[slow] != nums[fast]){
                    slow++;
                    // 维护 nums[0..slow] ⽆重复
                    nums[slow] = nums[fast];
                }
                fast++;
            }
            // 返回数组长度
            return slow+1;
        }
    }
}
